//
//  HomeTitleButton.swift
//  vveboSwiftPro
//
//  Created by 杨笑怡 on 15/6/30.
//  Copyright © 2015年 YangXiaoYi. All rights reserved.
//

import UIKit

class HomeTitleButton: UIButton {
    
    class func button(title:String) -> HomeTitleButton {
        
        let btn = HomeTitleButton()
        //        titleBtn.frame = CGRectMake(0, 0, 120, 30)
        btn.setTitle(title, forState: UIControlState.Normal)
        btn.setTitleColor(UIColor.darkTextColor(), forState: UIControlState.Normal)
        btn.titleLabel?.font = UIFont.systemFontOfSize(17)
        btn.setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal)
        btn.sizeToFit()
        
        return btn
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        
        let tFrame = titleLabel!.center
        titleLabel!.center = tFrame
        
        var iFrame = imageView!.frame
        let tMaxY = CGRectGetMaxX(titleLabel!.frame)
        iFrame.origin.x = tMaxY + 5
        imageView!.frame = iFrame
        
    }

}
